<?php
    @include_once("conn.php");
    @include_once("common.php");  

    @header("Content-Type:text/json;charset=utf-8");
    
    $id = $_GET["gid"];
    if(!$id){
        argErr();
    }

    //  执行查询语句  => 结果对象
    $search = "select id,goodsId,goodsName,goodsPrice,goodsImg,goodsMsg from `xm` where goodsId = '$id'";
    $result = mysqli_query($conn,$search);
    // print_r($result);

    $item = mysqli_fetch_assoc($result);
    
    $msg = array();
    if($item){
        // 数据的预处理   $item  每次查询的数据
        $item["goodsImg"] = explode(",",$item["goodsImg"]);

    
        $msg["status"] = true;
        $msg["detail"] = "ok";
        $msg["data"] = $item;
    }else{
        $msg["status"] = false;
        $msg["detail"] = "false";
      
    }

    echo json_encode($msg);  // 将数据转为json类型的字符串  并输出

?>